package fr.guy.aurelie.eportfolio.client.view;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;

import fr.guy.aurelie.eportfolio.client.helper.MyResources;
import fr.guy.aurelie.eportfolio.client.presenter.MyInfosPresenter;

public class MyInfosView extends Composite implements MyInfosPresenter.Display {
	private final VerticalPanel mainPanel;
	private final AbsolutePanel topPanel;
	private final AbsolutePanel bottomPanel;
	private final HTML coordinatePanel;
	private final VerticalPanel photoPanel;
	private final HTML persoInfosPanel;

	public static final int PANEL_TOP = 20;
	public static final int PANEL_LEFT = 20;

	public MyInfosView() {
		DecoratorPanel decoratorPanel = new DecoratorPanel();
		initWidget(decoratorPanel);

		mainPanel = new VerticalPanel();
		topPanel = new AbsolutePanel();
		topPanel.setSize("700px", "245px");
		bottomPanel = new AbsolutePanel();
		bottomPanel.setSize("700px", "170px");
		coordinatePanel = new HTML();
		photoPanel = new VerticalPanel();
		persoInfosPanel = new HTML();

		Image photo = new Image(MyResources.INSTANCE.aurelieGuyPhoto());
		String name = new String("<h2>Aurélie GUY</h2>");
//		Integer birthYear = 1988;
//		DateFormat dateFormat = DateFormat.getDateInstance(
//				DateFormat.YEAR_FIELD, Locale.FRANCE);
//		Integer yearsOld = birthYear
//				- Integer.valueOf(dateFormat.format(new Date()));
//		String yearsOldAsStr = new String(yearsOld + " ans"); // TODO date
//																// format in
//																// helper
		
		Integer yearsOld = 22;
		String yearsOldAsStr = new String(yearsOld + " ans");
		String driveLicence = new String("Permis B");

		String coordinatesTitle = new String("<h2>Mes coordonnées</h2>");
		String addressTitle = new String("<b>Adresse</b>");
		String address = new String("52, rue Alexandre Desrousseaux");
		String addressOther = new String("Appt. 1");
		String town = new String("59160 LOMME (LILLE)");
		String phoneTitle = new String("<b>Téléphone</b>");
		String phone = new String("06.29.18.63.83");
		String emailTitle = new String("<b>Email</b>");
		String email = new String(
				"<a href=\"mailTo:aurelie.guy@bbox.fr\">aurelie.guy@bbox.fr</a>");

		photoPanel.add(photo);
		persoInfosPanel.setHTML(name + "<br />" + yearsOldAsStr + "<br />"
				+ driveLicence);
		persoInfosPanel.setHeight("240px");
		persoInfosPanel.addStyleName("rightBorder");
		coordinatePanel.setHTML("<div>" + coordinatesTitle + "<br />"
				+ addressTitle + "<br />" + address + "<br />" + addressOther
				+ "<br />" + town + "<br /><br />" + phoneTitle + "<br />"
				+ phone + "<br /><br />" + emailTitle + "<br />" + email
				+ "</div>");

		topPanel.add(photoPanel, 20 + PANEL_LEFT, 0 + PANEL_TOP);
		topPanel.add(persoInfosPanel, 175 + PANEL_LEFT, 0 + PANEL_TOP);
		topPanel.add(coordinatePanel, 425 + PANEL_LEFT, 0 + PANEL_TOP);

		topPanel.addStyleName("borderPanel");

		mainPanel.add(topPanel);
		decoratorPanel.add(mainPanel);
	}
}
